package com.example.springboottest.controller;

import com.example.springboottest.domain.Person;
import com.example.springboottest.repository.IPersonRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ljw
 * @description
 * @date 2022/9/28 7:55
 */
@RestController
@RequestMapping("/person")
public class PersonController {
    
    @Autowired
    private IPersonRepository personRepository;
    
    /**
     * produces 指定返回的内容类型
     */
    @RequestMapping(method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE})
    public List<Person> findAll() {
        return personRepository.findAll();
    }
}
